// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.subscribeMessage.send({
        "touser": 'obTdMvtH1d19dZAw7yU7KkWoDWxM', //目标用户openid
        "page": 'page/home/index',
        "lang": 'zh_CN',
        "data": {
          "time2": {
            "value": '2025-07-29'
          },
          "thing1": {
            "value": '冥想打卡'
          },
          "thing4": {
            "value": '开始今天的冥想打卡吧'
          }
        },
        "templateId": 'ZnXF5XmsZvMAw5T7FYnbbWf4NEk8H8aRWGjBsgUJhk8',
        "miniprogramState": 'trial'
      })
    return result
  } catch (err) {
    return err
  }
}